package programmercarl.动态规划.C24;

class Solution {
    public int numSquares(int n) {
        int[] dp = new int[n + 1];
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            dp[i]=Integer.MAX_VALUE;
        }
        //物品最多到100
        for (int i = 1; i <= n; i++) {//物品
            for (int j = i*i; j <= n; j++) {
                dp[j]=Math.min(dp[j], dp[j-i*i]+1);
            }
        }
        return dp[n];
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.numSquares(12);
    }
}